package android.pruebas.dialog1;

import android.app.Activity;
import android.os.Bundle;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class Dialog1Activity extends Activity {
	
/** Called when the activity is first created. */

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

	}

	

	@Override
	protected Dialog onCreateDialog(int id) {
        switch (id) {
        case 10:
            // Create out AlterDialog
            Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("¿Quieres salir de la actividad?");
            builder.setCancelable(true);
            builder.setPositiveButton("Si, quiero salir", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                	Dialog1Activity.this.finish();
                }
            });
            builder.setNegativeButton("No. Me quedo donde estoy", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    Toast.makeText(getApplicationContext(),"Hola de nuevo",Toast.LENGTH_LONG).show();
                }
            });
            AlertDialog dialog = builder.create();
            dialog.show();
        }
        return super.onCreateDialog(id);
    }

	
	// Método declarado en el layout.
	public void abrirDialogo(View view) {
		this.showDialog(10);
	}

}
		